

#include <iostream>
#include <assert.h>
#include <string.h>

using std::endl;
using std::cout;
using std::cin;

class A
{
public:
    A(int a = 0, int i = 0)
        :_a(a)
        , _i(i)
    {}

    A(const A& a)
    {
        _a = a._a;
        _i = a._i;
    }

    void Print()
    {
        cout << _a << ' ' << _i << endl;
    }

    int Geta()
    {
        return _a;
    }

    int Geti()
    {
        return _i;
    }

private:
    int _a;
    int _i;
};

class B
{
public:
    


private:
    int _b;
    int _i;
};

class Stack 
{
public:
    
    Stack(int capacity = 4)
    {
        cout << "构造函数" << endl;
        _a = new int[capacity];
        assert(_a);

        _top = 0;
        _capacity = capacity;
    }

    ~Stack()
    {
        delete[] _a;
        _top = _capacity = 0;
    }

    Stack(const Stack& st)
    {
        cout << "拷贝构造" << endl;
        _a = new int[st._capacity];
        assert(_a);

        memcpy(_a, st._a, sizeof(int) * st._top);

        _top = st._top;
        _capacity = st._capacity;
    }

    int size() const 
    {
        return _top;
    }

    void Print()
    {
        for (int i = 0; i < size(); i ++ )
        {
            printf("%d ", _a[i]);
        }
        printf("\n");
    }

    void push(int x)
    {
        _a[_top ++ ] = x;
    }

    int* _a;
    int _top;
    int _capacity;
};

const Stack& func1(const Stack& s1)
{
    return s1;
}

int main()
{
   // A a1;
   // A a2(100, 10);

   // a1.Print();
   // a2.Print();

   // for (int i = a2.Geti(); i <= a2.Geta(); i ++ )
   // {
   //     printf("%d ", i);
   //     if (((i + 1) % 5) == 0)
   //     {
   //         printf("\n");
   //     }
   // }
   //
   //
    
//    Stack s1;
//    
//    Stack s2 = func1(s1);
//
//    cout << "s2: " << s2._a << endl << "s1: " << s1._a << endl; 
//
//    cout << "s2: " << &s2 << ' ' << "s1: " << &s1 << endl;
//
//    cout << endl << endl;
//
//    Stack s3;
//
//    const Stack& s4 = func1(s3); 
//
//    cout << "s3: " << s3._a << endl << "s4: " << s4._a << endl;
//
//    cout << "s3: " << &s3 << endl << "s4: " << &s4 << endl;

    Stack s1;

    s1.push(1);
    s1.push(2);
    s1.push(3);
    s1.push(4);

    s1.Print();

    return 0;
}
